<section class="tlp-pane-section pull-request-tab-content">
    <section id="pull-request-overview">
        <div class="pull-request-top-actions">
            <button class="tlp-button-primary tlp-button-outline tlp-button-small" ng-click="overview.showEditionForm()">
                <i class="tlp-button-icon fa fa-pencil"></i> {{ ::'Edit message' | translate }}
            </button>

            <div class="tlp-dropdown pull-request-checkout-dropdown">
                <button id="pull-request-checkout-dropdown"
                    class="tlp-button-primary tlp-button-outline tlp-button-small"
                    type="button"
                >
                    <i class="tlp-button-icon fa fa-arrow-circle-o-down"></i> {{ ::'Checkout' | translate }}
                    <i class="tlp-button-icon-right fa fa-caret-down"></i>
                </button>

                <div class="tlp-dropdown-menu pull-request-checkout-menu"
                    ng-click="$event.stopPropagation()"
                    role="menu"
                >
                    <div class="pull-request-checkout-menu-content">
                        <span class="pull-request-checkout-menu-label" translate>Checkout with</span>
                        <select class="tlp-select tlp-select-adjusted tlp-select-small"
                            ng-model="overview.current_checkout_method"
                        >
                            <option ng-if="overview.pull_request.repository_dest.clone_ssh_url"
                                value="ssh"
                            >SSH</option>
                            <option ng-if="overview.pull_request.repository_dest.clone_http_url"
                                value="http"
                            >HTTPS</option>
                        </select>
                    </div>
                    <pre class="pull-request-checkout-commands">
<code class="pull-request-checkout-command">git fetch {{ overview.getCloneUrl(overview.current_checkout_method) }} {{ ::overview.pull_request.head_reference }}</code>
<code class="pull-request-checkout-command">git checkout FETCH_HEAD</code>
</pre>
                </div>
            </div>
        </div>

        <div class="pull-request-requester-date-changes">
            <tuleap-username username="overview.author"></tuleap-username>
            <span class="tlp-text-muted pull-request-date">
                <i class="fa fa-clock-o"></i> {{ overview.pull_request.creation_date | amDateFormat: 'YYYY-MM-DD HH:mm' }}
            </span>
            <div class="pull-request-changes">
                <span class="tlp-text-success">+{{ overview.pull_request.short_stat.lines_added }}</span>
                <span class="tlp-text-danger">-{{ overview.pull_request.short_stat.lines_removed }}</span>
            </div>
        </div>

        <blockquote class="pull-request-description" ng-bind-html="overview.pull_request.description"></blockquote>

        <div class="pull-request-references-ci">
            <div class="pull-request-references">
                <p class="tlp-text-muted pull-request-reference">{{ overview.pull_request.reference_src }}</p>
                <pull-request-refs class="pull-request-refs" pull-request-data="overview.pull_request"></pull-request-refs>
            </div>

            <div class="tlp-property pull-request-ci">
                <label class="tlp-label">{{ 'Last CI Status' | translate }}</label>
                <p class="tlp-text-success" ng-if="overview.buildStatusIs('success')">
                    <i class="fa fa-check"></i> <span translate>Success on {{ overview.pull_request.last_build_date | amDateFormat: 'YYYY-MM-DD HH:mm' }}</span>
                </p>
                <p class="tlp-text-danger" ng-if="overview.buildStatusIs('fail')">
                    <i class="fa fa-remove"></i> <span translate>Failure on {{ overview.pull_request.last_build_date | amDateFormat: 'YYYY-MM-DD HH:mm' }}</span>
                </p>
                <p class="tlp-text-warning" ng-if="overview.buildStatusIs('unknown')">
                    <i class="fa fa-exclamation-triangle"></i> <span translate>Unknown</span>
                </p>
                <p class="tlp-text-warning warning-deprecation-build-status-rest-route"
                    ng-if="overview.pull_request.build_status_with_deprecated_route"
                    title="{{ 'Your CI job is using a deprecated REST route to publish the build result and must be updated. Consult the documentation or the API Explorer for more information.' | translate }}"
                >
                    <i class="fa fa-exclamation-triangle"></i><span translate>Deprecated REST route</span>
                </p>
            </div>
        </div>

        <div id="pull-request-actions">
            <div ng-if="overview.operationInProgress" class="loading"></div>

            <div ng-if="overview.isNonFastForwardMerge() && overview.is_merge_commit_allowed">
                <button ng-if="overview.hasMergeRight()" class="tlp-button-warning" ng-disabled="overview.operationInProgress" ng-click="overview.checkMerge()">
                    <i class="tlp-button-icon fa fa-code-fork fa-rotate-270"></i> {{ 'Merge' | translate }}
                </button>
                <button ng-if="overview.hasAbandonRight()" class="tlp-button-danger" ng-disabled="overview.operationInProgress" ng-click="overview.abandon()">
                    <i class="tlp-button-icon fa fa-trash-o"></i> {{ 'Abandon' | translate }}
                </button>
            </div>

            <div ng-if="overview.isNonFastForwardMerge() && ! overview.is_merge_commit_allowed" class="tlp-alert-danger">
                <i class="fa fa-times-circle"></i>
                {{ "Merge commits are forbidden in the repository configuration (fast-forward only). Please rebase the commit and update the pull request." | translate }}
                <div>
                    <button class="tlp-button-warning" disabled="true">
                        <i class="tlp-button-icon fa fa-code-fork fa-rotate-270"></i> {{ 'Merge' | translate }}
                    </button>
                    <button ng-if="overview.hasAbandonRight()" class="tlp-button-danger" ng-disabled="overview.operationInProgress" ng-click="overview.abandon()">
                        <i class="tlp-button-icon fa fa-trash-o"></i> {{ 'Abandon' | translate }}
                    </button>
                </div>
            </div>

            <div ng-if="overview.isConflictingMerge()" class="tlp-alert-danger">
                <i class="fa fa-times-circle"></i>
                {{ 'Pull request can not be merged automatically due to conflicts with destination. Resolve conflicts on the command line and update the pull request.' | translate }}
                <div>
                    <button ng-if="overview.hasMergeRight()" class="tlp-button-warning" disabled="true">
                        <i class="tlp-button-icon fa fa-code-fork fa-rotate-270"></i> {{ 'Merge' | translate }}
                    </button>
                    <button ng-if="overview.hasAbandonRight()" class="tlp-button-danger" ng-disabled="overview.operationInProgress" ng-click="overview.abandon()">
                        <i class="tlp-button-icon fa fa-trash-o"></i> {{ 'Abandon' | translate }}
                    </button>
                </div>
            </div>

            <div ng-if="overview.isUnknownMerge()" class="tlp-alert-warning">
                <i class="fa fa-warning"></i>
                {{ 'Pull request mergeability with destination is not determined. You can merge on the command line and push to destination.' | translate }}
                <div>
                    <button ng-if="overview.hasMergeRight()" class="tlp-button-warning" disabled="true">
                        <i class="tlp-button-icon fa fa-code-fork fa-rotate-270"></i> {{ 'Merge' | translate }}
                    </button>
                    <button ng-if="overview.hasAbandonRight()" class="tlp-button-danger" ng-disabled="overview.operationInProgress" ng-click="overview.abandon()">
                        <i class="tlp-button-icon fa fa-trash-o"></i> {{ 'Abandon' | translate }}
                    </button>
                </div>
            </div>

            <div ng-if="! overview.isConflictingMerge() && ! overview.isUnknownMerge() && ! overview.isNonFastForwardMerge()">
                <button ng-if="overview.hasMergeRight()" class="tlp-button-success" ng-disabled="overview.operationInProgress" ng-click="overview.checkMerge()">
                    <i class="tlp-button-icon fa fa-code-fork fa-rotate-270"></i> {{ 'Merge' | translate }}
                </button>
                <button ng-if="overview.hasAbandonRight()" class="tlp-button-danger" ng-disabled="overview.operationInProgress" ng-click="overview.abandon()">
                    <i class="tlp-button-icon fa fa-trash-o"></i> {{ 'Abandon' | translate }}
                </button>
            </div>

            <button ng-if="overview.pull_request.status === overview.valid_status_keys.abandon" class="tlp-button-danger" disabled translate>
                Abandoned
            </button>
            <button ng-if="overview.pull_request.status === overview.valid_status_keys.merge" class="tlp-button-success" disabled translate>
                Already merged
            </button>
        </div>
    </section>

    <section ui-view="timeline" class="pull-request-timeline"></section>
</section>
